<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of delete</title>
  <meta name="keywords" content="delete">
  <meta name="description" content="delete --- delete vertices or edges from a graph">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../index.html">Home</a> &gt;  <a href="../index.html">matgraph</a> &gt; <a href="index.html">@graph</a> &gt; delete.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../index.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="index.html">Index for matgraph/@graph&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>delete
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>delete --- delete vertices or edges from a graph</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function delete(g,i,j) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment"> delete --- delete vertices or edges from a graph
 delete(g,v) --- delete vertex v
 delete(g,vlist) --- delete vertices in column vector v
 delete(g,i,j) --- delete edge ij
 delete(g,elist) --- delete edges in m-by-2 array elist</pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="delete.html" class="code" title="function delete(g,i,j)">delete</a>	delete --- delete vertices or edges from a graph</li><li><a href="hasxy.html" class="code" title="function yn = hasxy(g)">hasxy</a>	hasxy(g) --- determine if an embedding has been created for g</li><li><a href="is_labeled.html" class="code" title="function yn = is_labeled(g)">is_labeled</a>	is_labeled(g) --- determine if there are labels on vertices.</li><li><a href="nv.html" class="code" title="function n = nv(g)">nv</a>	nv(g) --- number of vertices in g</li><li><a href="size.html" class="code" title="function [sz,tz] = size(g)">size</a>	size(g) --- returns [nv,ne] for the graph</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="bridges.html" class="code" title="function blist = bridges(g,algo)">bridges</a>	bridges(g,algo) --- find all cut edges in g</li><li><a href="contract.html" class="code" title="function contract(g,u,v)">contract</a>	contract(g,u,v) --- contract v into u</li><li><a href="delete.html" class="code" title="function delete(g,i,j)">delete</a>	delete --- delete vertices or edges from a graph</li><li><a href="euler_trail.html" class="code" title="function [elist, exists] = euler_trail(g)">euler_trail</a>	euler_trail(g) --- find an euler trail in g (if one exists)</li><li><a href="iso.html" class="code" title="function [yn,p] = iso(g,h,options)">iso</a>	[yn,p] = iso(g,h,options) --- is g isomorphic to h?</li><li><a href="prufer.html" class="code" title="function output = prufer(g, code)">prufer</a>	prufer --- convert a tree to/from its Prufer code</li><li><a href="trim.html" class="code" title="function trim(g,d)">trim</a>	trim(g,d) --- iteratively remove vertices of degree at most d</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function delete(g,i,j)</a>
0002 <span class="comment">% delete --- delete vertices or edges from a graph</span>
0003 <span class="comment">% delete(g,v) --- delete vertex v</span>
0004 <span class="comment">% delete(g,vlist) --- delete vertices in column vector v</span>
0005 <span class="comment">% delete(g,i,j) --- delete edge ij</span>
0006 <span class="comment">% delete(g,elist) --- delete edges in m-by-2 array elist</span>
0007 
0008 <span class="keyword">global</span> GRAPH_MAGIC
0009 
0010 n = <a href="nv.html" class="code" title="function n = nv(g)">nv</a>(g);
0011 
0012 <span class="keyword">if</span> nargin==3   <span class="comment">% simple delete an edge</span>
0013    <span class="keyword">if</span> (i&lt;1) || (i&gt;n) || (j&lt;1) || (j&gt;n) 
0014        <span class="keyword">return</span>
0015    <span class="keyword">end</span>
0016    GRAPH_MAGIC.graphs{g.idx}.array(i,j) = 0;
0017    GRAPH_MAGIC.graphs{g.idx}.array(j,i) = 0;
0018    <span class="keyword">return</span>
0019 <span class="keyword">end</span>
0020 
0021 <span class="comment">% from here on, we're in the single argument case</span>
0022 
0023 [nr,nc] = <a href="size.html" class="code" title="function [sz,tz] = size(g)">size</a>(i);
0024 
0025 <span class="comment">% delete a set of vertices (or a single vertex)</span>
0026 
0027 <span class="keyword">if</span>  (nc==1)
0028     kill_list = i(find((i&gt;0) &amp; (i&lt;=n)));
0029     keep_list = setdiff(1:n,kill_list);
0030     <span class="keyword">if</span> <a href="hasxy.html" class="code" title="function yn = hasxy(g)">hasxy</a>(g)
0031         GRAPH_MAGIC.graphs{g.idx}.xy = <span class="keyword">...</span>
0032             GRAPH_MAGIC.graphs{g.idx}.xy(keep_list,:);
0033     <span class="keyword">end</span>
0034     <span class="keyword">if</span> <a href="is_labeled.html" class="code" title="function yn = is_labeled(g)">is_labeled</a>(g)
0035         GRAPH_MAGIC.graphs{g.idx}.labels = <span class="keyword">...</span>
0036             GRAPH_MAGIC.graphs{g.idx}.labels(keep_list);
0037     <span class="keyword">end</span>
0038     GRAPH_MAGIC.graphs{g.idx}.array = <span class="keyword">...</span>
0039         GRAPH_MAGIC.graphs{g.idx}.array(keep_list,keep_list);
0040     <span class="keyword">return</span>
0041 <span class="keyword">end</span>
0042 
0043 
0044 <span class="keyword">if</span> (nr==1) &amp;&amp; (nc ~=2)
0045     error(<span class="string">'for delete(g,vlist), vlist must be a single COLUMN vector'</span>);
0046 <span class="keyword">end</span>
0047 
0048 <span class="comment">% finally, we're in the delete a list of edges case</span>
0049 
0050 <span class="keyword">if</span> (nc ~= 2)
0051     error(<span class="string">'delete(elist) requires elist to have exactly two columns'</span>)
0052 <span class="keyword">end</span>
0053 
0054 <span class="keyword">for</span> k=1:nr
0055     <a href="delete.html" class="code" title="function delete(g,i,j)">delete</a>(g,i(k,1),i(k,2));
0056 <span class="keyword">end</span>
0057     
0058</pre></div>
<hr><address>Generated on Fri 30-Apr-2010 07:51:16 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>